{% extends 'base.html' %}
{% block content %}
<div class="container mt-4">
    <h2>文档列表</h2>
    <div class="mb-3 row">
        <div class="col-md-6">
            <a href="{% url 'doc_manager:document_create' %}" class="btn btn-primary">上传新文档</a>
        </div>
        <div class="col-md-6">
            <form class="form-inline float-right" method="get">
                <div class="input-group">
                    <input type="text" class="form-control" name="q" placeholder="搜索文档..." value="{{ request.GET.q }}">
                    <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="submit">搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>标题</th>
                <th>分类</th>
                <th>状态</th>
                <th>创建者</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for document in documents %}
            <tr>
                <td>{{ document.title }}</td>
                <td>{{ document.category }}</td>
                <td>{{ document.status }}</td>
                <td>{{ document.created_by }}</td>
                <td>{{ document.created_at }}</td>
                <td>
                    <a href="{% url 'doc_manager:document_detail' document.id %}" class="btn btn-sm btn-info">查看</a>
                    <a href="{% url 'doc_manager:document_update' document.id %}" class="btn btn-sm btn-warning">编辑</a>
                    <a href="{% url 'doc_manager:document_delete' document.id %}" class="btn btn-sm btn-danger">删除</a>
                </td>
            </tr>
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
  
{% include "doc_manager/pagination.html" %}
{% endblock %}